package com.association.service.impl;

import com.association.mapper.WebProjectMapper;
import com.association.model.entity.Menu;
import com.association.service.MenuService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.len.base.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 18244
 */
@Service
public class MenuServiceImpl extends BaseServiceImpl<Menu, String> implements MenuService {

    @Resource
    WebProjectMapper webProjectMapper;

    @Override
    public List<Menu> menuList() {
        List<Menu> menuList = this.list(new QueryWrapper<Menu>().eq("pid", 0).eq("is_del", 0));
        menuList.forEach(res -> {
            res.setChildren(this.list(new QueryWrapper<Menu>().eq("pid", res.getId())));
            res.getChildren().forEach(date -> {
                date.setChildren(this.list(new QueryWrapper<Menu>().eq("pid", date.getId())));
            });
        });
        return menuList;
    }

    @Override
    public List<Menu> menuRouterList() {
        QueryWrapper<Menu> menuQueryWrapper = new QueryWrapper<>();
        menuQueryWrapper.ne("type", 2);
        menuQueryWrapper.eq("is_del", 0);
        List<Menu> menuList = this.list(menuQueryWrapper);
        return menuList;
    }


}
